package com.fks.fks_service.utils;

import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ProxyCommissionRecordSql {

    //按条件获取商品列表
    public static String selectList(Map params) {
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        String title = String.valueOf(params.get("title"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        String categoryName = String.valueOf(params.get("categoryName"));
        String status = String.valueOf(params.get("status"));
        String isDelete = String.valueOf(params.get("isDelete"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_shop where 1=1");
        if (id!=0){
            sqlStr.append(" and id = '");
            sqlStr.append(id);
            sqlStr.append("'");
        }
        if (!title.equals("")) {
            sqlStr.append(" and (title LIKE '%"+title+"%' )");
        }
        if (!categoryName.equals("")) {
            sqlStr.append(" and ( (categoryName1 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName2 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName3 LIKE '%"+categoryName+"%' ))");
        }
        if ("1".equals(status)||"2".equals(status)){
            sqlStr.append(" and status = '");
            sqlStr.append(status);
            sqlStr.append("'");
        }
        if (!"".equals(isDelete)){
            sqlStr.append(" and isDelete = '");
            sqlStr.append(isDelete);
            sqlStr.append("'");
        }

        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台商品列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取商品列表数量
    public static String selectListNumber(Map params) {
        String title = String.valueOf(params.get("title"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        String categoryName = String.valueOf(params.get("categoryName"));
        String status = String.valueOf(params.get("status"));
        String isDelete = String.valueOf(params.get("isDelete"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_shop where 1=1 ");
        if (id!=0){
            sqlStr.append(" and id = '");
            sqlStr.append(id);
            sqlStr.append("'");
        }
        if (!title.equals("")) {
            sqlStr.append(" and (title LIKE '%"+title+"%' )");
        }
        if (!categoryName.equals("")) {
            sqlStr.append(" and ( (categoryName1 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName2 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName3 LIKE '%"+categoryName+"%' ))");
        }
        if ("1".equals(status)||"2".equals(status)){
            sqlStr.append(" and status = '");
            sqlStr.append(status);
            sqlStr.append("'");
        }
        if (!"".equals(isDelete)){
            sqlStr.append(" and isDelete = '");
            sqlStr.append(isDelete);
            sqlStr.append("'");
        }
        System.out.println("灵灵享租后台商品列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }


    //按条件获取订单列表
    public static String selectShopOrderList(Map params){
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        int merchantUserId = Integer.parseInt(String.valueOf(params.get("merchantUserId")));
        String shopTitle = String.valueOf(params.get("shopTitle"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_shop_order where isDelete=0 and merchantUserId='"+merchantUserId+"' ");
        if (!shopTitle.equals("")) {
            sqlStr.append(" and (shopTitle LIKE '%"+shopTitle+"%' )");
        }
        if (id!=0) {
            sqlStr.append(" and id='"+id+"' ");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台订单列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取订单列表
    public static String selectShopOrderList2(Map params){
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        int merchantUserId = Integer.parseInt(String.valueOf(params.get("merchantUserId")));
        String shopTitle = String.valueOf(params.get("shopTitle"));
        String status = String.valueOf(params.get("status"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_shop_order where isDelete=0 and status='"+status+"' and merchantUserId='"+merchantUserId+"' ");
        if (!shopTitle.equals("")) {
            sqlStr.append(" and (shopTitle LIKE '%"+shopTitle+"%' )");
        }
        if (id!=0) {
            sqlStr.append(" and id='"+id+"' ");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台订单列表--"+sqlStr.toString());
        return sqlStr.toString();
    }


    //按条件获取订单列表数量
    public static String selectShopOrderListNumber(Map params){
        int merchantUserId = Integer.parseInt(String.valueOf(params.get("merchantUserId")));
        String shopTitle = String.valueOf(params.get("shopTitle"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_shop_order where isDelete=0 and merchantUserId='"+merchantUserId+"' ");
        if (!shopTitle.equals("")) {
            sqlStr.append(" and (shopTitle LIKE '%"+shopTitle+"%' )");
        }
        if (id!=0) {
            sqlStr.append(" and id = '"+id+"' ");
        }
        System.out.println("灵灵享租后台订单列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取订单列表数量
    public static String selectShopOrderListNumber2(Map params){
        int merchantUserId = Integer.parseInt(String.valueOf(params.get("merchantUserId")));
        String shopTitle = String.valueOf(params.get("shopTitle"));
        String status = String.valueOf(params.get("status"));
        int id = Integer.parseInt(String.valueOf(params.get("id")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_shop_order where isDelete=0 and status='"+status+"' and merchantUserId='"+merchantUserId+"' ");
        if (!shopTitle.equals("")) {
            sqlStr.append(" and (shopTitle LIKE '%"+shopTitle+"%' )");
        }
        if (id!=0) {
            sqlStr.append(" and id = '"+id+"' ");
        }
        System.out.println("灵灵享租后台订单列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }


    //按条件获取优惠卷列表
    public static String selectCouponList(Map params){
        String merchantUserId = String.valueOf(params.get("merchantUserId"));
        String couponName = String.valueOf(params.get("couponName"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String ageing = String.valueOf(params.get("ageing"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_coupon where isDelete=0 and merchantUserId='"+merchantUserId+"' ");
        if ("".equals(couponName)) {
            sqlStr.append(" and couponName = '");
            sqlStr.append(couponName);
            sqlStr.append("'");
        }
        if ("".equals(ageing)) {
            sqlStr.append(" and ageing = '");
            sqlStr.append(ageing);
            sqlStr.append("'");
        }
        if (!"".equals(startTime)){
            sqlStr.append(" and createTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!"".equals(endTime)){
            sqlStr.append(" and endTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append(page);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台优惠卷列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取采购列表
    public static String selectProcureList(Map params){
        String procureNumber = String.valueOf(params.get("procureNumber"));
        String phoneSerialNumber = String.valueOf(params.get("phoneSerialNumber"));
        String invoice = String.valueOf(params.get("invoice"));
        String purchaser = String.valueOf(params.get("purchaser"));
        String procurementSource = String.valueOf(params.get("procurementSource"));
        String merchantId = String.valueOf(params.get("merchantId"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_procure where isDelete=0 and merchantId='"+merchantId+"' ");
        if (!"".equals(procureNumber)) {
            sqlStr.append(" and procureNumber = '");
            sqlStr.append(procureNumber);
            sqlStr.append("'");
        }
        if (!"".equals(phoneSerialNumber)) {
            sqlStr.append(" and phoneSerialNumber = '");
            sqlStr.append(phoneSerialNumber);
            sqlStr.append("'");
        }
        if (!"".equals(invoice)){
            sqlStr.append(" and invoice = '");
            sqlStr.append(invoice);
            sqlStr.append("'");
        }
        if (!"".equals(purchaser)){
            sqlStr.append(" and (purchaser LIKE '%"+purchaser+"%' )");
        }
        if (!"".equals(procurementSource)){
            sqlStr.append(" and (procurementSource LIKE '%"+procurementSource+"%' )");
        }
        if (!"".equals(startTime)){
            sqlStr.append(" and enterTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!"".equals(endTime)){
            sqlStr.append(" and enterTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台采购列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取采购列表数量
    public static String selectProcureListNumber(Map params){
        String procureNumber = String.valueOf(params.get("procureNumber"));
        String phoneSerialNumber = String.valueOf(params.get("phoneSerialNumber"));
        String invoice = String.valueOf(params.get("invoice"));
        String purchaser = String.valueOf(params.get("purchaser"));
        String procurementSource = String.valueOf(params.get("procurementSource"));
        String merchantId = String.valueOf(params.get("merchantId"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_procure where isDelete=0 and merchantId='"+merchantId+"' ");
        if (!"".equals(procureNumber)) {
            sqlStr.append(" and procureNumber = '");
            sqlStr.append(procureNumber);
            sqlStr.append("'");
        }
        if (!"".equals(phoneSerialNumber)) {
            sqlStr.append(" and phoneSerialNumber = '");
            sqlStr.append(phoneSerialNumber);
            sqlStr.append("'");
        }
        if (!"".equals(invoice)){
            sqlStr.append(" and invoice = '");
            sqlStr.append(invoice);
            sqlStr.append("'");
        }
        if (!"".equals(purchaser)){
            sqlStr.append(" and (purchaser LIKE '%"+purchaser+"%' )");
        }
        if (!"".equals(procurementSource)){
            sqlStr.append(" and (purchaser LIKE '%"+procurementSource+"%' )");
        }
        System.out.println("灵灵享租后台采购列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取财务列表
    public static String selectFundDetailsList(Map params){
        String merchantId = String.valueOf(params.get("merchantId"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String procurementSource = String.valueOf(params.get("procurementSource"));
        String shopName = String.valueOf(params.get("shopName"));
        String minmumPurchaseAmount = String.valueOf(params.get("minmumPurchaseAmount"));
        String maximumPurchaseAmount = String.valueOf(params.get("maximumPurchaseAmount"));
        String invoice = String.valueOf(params.get("invoice"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_fund_details where merchantId='"+merchantId+"' ");
        if (!"".equals(startTime)) {
            sqlStr.append(" and fundChangeTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!"".equals(endTime)) {
            sqlStr.append(" and fundChangeTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!"".equals(procurementSource)) {
            sqlStr.append(" and (procurementSource LIKE '%"+procurementSource+"%' )");
        }
        if (!"".equals(shopName)) {
            sqlStr.append(" and (title LIKE '%"+shopName+"%' )");
        }
        if (!"".equals(minmumPurchaseAmount)){
            sqlStr.append(" and purchasePrice > '");
            sqlStr.append(minmumPurchaseAmount);
            sqlStr.append("'");
        }
        if (!"".equals(maximumPurchaseAmount)){
            sqlStr.append(" and purchasePrice < '");
            sqlStr.append(maximumPurchaseAmount);
            sqlStr.append("'");
        }
        if (!"".equals(invoice)) {
            sqlStr.append(" and (invoice LIKE '%"+invoice+"%' )");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append(pageSize);
        }
        System.out.println("灵灵享租后台财务列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取财务列表
    public static String selectFundDetailsListNumber(Map params){
        String merchantId = String.valueOf(params.get("merchantId"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String procurementSource = String.valueOf(params.get("procurementSource"));
        String shopName = String.valueOf(params.get("shopName"));
        String minmumPurchaseAmount = String.valueOf(params.get("minmumPurchaseAmount"));
        String maximumPurchaseAmount = String.valueOf(params.get("maximumPurchaseAmount"));
        String invoice = String.valueOf(params.get("invoice"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_fund_details where merchantId='"+merchantId+"' ");
        if (!"".equals(startTime)) {
            sqlStr.append(" and fundChangeTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!"".equals(endTime)) {
            sqlStr.append(" and fundChangeTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!"".equals(procurementSource)) {
            sqlStr.append(" and (procurementSource LIKE '%"+procurementSource+"%' )");
        }
        if (!"".equals(shopName)) {
            sqlStr.append(" and (title LIKE '%"+shopName+"%' )");
        }
        if (!"".equals(minmumPurchaseAmount)){
            sqlStr.append(" and purchasePrice > '");
            sqlStr.append(minmumPurchaseAmount);
            sqlStr.append("'");
        }
        if (!"".equals(maximumPurchaseAmount)){
            sqlStr.append(" and purchasePrice < '");
            sqlStr.append(maximumPurchaseAmount);
            sqlStr.append("'");
        }
        if (!"".equals(invoice)) {
            sqlStr.append(" and (invoice LIKE '%"+invoice+"%' )");
        }
        System.out.println("灵灵享租后台财务列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取采购列表
    public static String getShopReleaseRecord(Map params){
        String id = String.valueOf(params.get("id"));
        String title = String.valueOf(params.get("title"));
        String updateStatus = String.valueOf(params.get("updateStatus"));
        String newOldDegree = String.valueOf(params.get("newOldDegree"));
        String categoryName = String.valueOf(params.get("categoryName"));
        String editingType = String.valueOf(params.get("editingType"));
        String merchantUserId = String.valueOf(params.get("merchantUserId"));
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_shop_release_record where merchantUserId='"+Integer.valueOf(merchantUserId)+"' ");
        if (!"".equals(id)) {
            sqlStr.append(" and shopId = '");
            sqlStr.append(Integer.valueOf(id));
            sqlStr.append("'");
        }
        if (!"".equals(title)) {
            sqlStr.append(" and (title LIKE '%"+title+"%' )");
        }
        if (!"".equals(updateStatus)){
            sqlStr.append(" and updateStatus = '");
            sqlStr.append(updateStatus);
            sqlStr.append("'");
        }
        if (!"".equals(newOldDegree)){
            sqlStr.append(" and newOldDegree = '");
            sqlStr.append(newOldDegree);
            sqlStr.append("'");
        }
        if (!categoryName.equals("")) {
            sqlStr.append(" and ( (categoryName1 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName2 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName3 LIKE '%"+categoryName+"%' ))");
        }
        if (!"".equals(editingType)){
            sqlStr.append(" and editingType = '");
            sqlStr.append(editingType);
            sqlStr.append("'");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append((pageSize));
        }
        System.out.println("灵灵享租采购列表--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取采购列表数量
    public static String getShopReleaseRecordNumber(Map params){
        String id = String.valueOf(params.get("id"));
        String title = String.valueOf(params.get("title"));
        String updateStatus = String.valueOf(params.get("updateStatus"));
        String newOldDegree = String.valueOf(params.get("newOldDegree"));
        String categoryName = String.valueOf(params.get("categoryName"));
        String editingType = String.valueOf(params.get("editingType"));
        String merchantUserId = String.valueOf(params.get("merchantUserId"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_shop_release_record where merchantUserId='"+Integer.valueOf(merchantUserId)+"' ");
        if (!"".equals(id)) {
            sqlStr.append(" and shopId = '");
            sqlStr.append(Integer.valueOf(id));
            sqlStr.append("'");
        }
        if (!"".equals(title)) {
            sqlStr.append(" and (title LIKE '%"+title+"%' )");
        }
        if (!"".equals(updateStatus)){
            sqlStr.append(" and updateStatus = '");
            sqlStr.append(updateStatus);
            sqlStr.append("'");
        }
        if (!"".equals(newOldDegree)){
            sqlStr.append(" and newOldDegree = '");
            sqlStr.append(newOldDegree);
            sqlStr.append("'");
        }
        if (!categoryName.equals("")) {
            sqlStr.append(" and ( (categoryName1 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName2 LIKE '%"+categoryName+"%' )");
            sqlStr.append(" or (categoryName3 LIKE '%"+categoryName+"%' ))");
        }
        if (!"".equals(editingType)){
            sqlStr.append(" and editingType = '");
            sqlStr.append(editingType);
            sqlStr.append("'");
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    //按条件获取采购列表数量
    public static String getServiceStaffList(Map params){
        int page = Integer.parseInt(String.valueOf(params.get("page")));
        int pageSize = Integer.parseInt(String.valueOf(params.get("pageSize")));
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        String serviceStaffPhone = String.valueOf(params.get("serviceStaffPhone"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_service_staff where status='1' and isDelete='0' ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!serviceStaffPhone.equals("")) {
            sqlStr.append(" and serviceStaffPhone LIKE '%"+serviceStaffPhone+"%' ");
        }
        if (page != 0 && pageSize != 0) {
            sqlStr.append(" limit ");
            sqlStr.append((page-1)*pageSize);
            sqlStr.append(",");
            sqlStr.append((pageSize));
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }


    public static String getServiceStaffListNumber(Map params){
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        String serviceStaffPhone = String.valueOf(params.get("serviceStaffPhone"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_service_staff where status='1' and isDelete='0' ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!serviceStaffPhone.equals("")) {
            sqlStr.append(" and serviceStaffPhone LIKE '%"+serviceStaffPhone+"%' ");
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    public static String getBalanceList2(Map params){
        int userId = Integer.valueOf(String.valueOf(params.get("userId")));
        int page = Integer.valueOf(String.valueOf(params.get("page")));
        int pageSize = Integer.valueOf(String.valueOf(params.get("pageSize")));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String title = String.valueOf(params.get("title"));
        String orderNo = String.valueOf(params.get("orderNo"));
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select * from fks_balance where merchantUserId="+userId+" ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!title.equals("")) {
            sqlStr.append(" and title LIKE '%"+title+"%' ");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and createTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and createTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        sqlStr.append(" limit ");
        sqlStr.append((page-1)*pageSize);
        sqlStr.append(",");
        sqlStr.append((pageSize));
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    public static String getBalanceList2Number(Map params){
        int userId = Integer.valueOf(String.valueOf(params.get("userId")));
        String balanceType = String.valueOf(params.get("balanceType"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String title = String.valueOf(params.get("title"));
        String orderNo = String.valueOf(params.get("orderNo"));
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_balance where merchantUserId="+userId+" ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!title.equals("")) {
            sqlStr.append(" and title LIKE '%"+title+"%' ");
        }
        if (!balanceType.equals("")) {
            sqlStr.append(" and balanceType = '");
            sqlStr.append(balanceType);
            sqlStr.append("'");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and createTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and createTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    public static String getBalanceList3(Map params){
        int userId = Integer.valueOf(String.valueOf(params.get("userId")));
        int page = Integer.valueOf(String.valueOf(params.get("page")));
        int pageSize = Integer.valueOf(String.valueOf(params.get("pageSize")));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String title = String.valueOf(params.get("title"));
        String orderNo = String.valueOf(params.get("orderNo"));
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_balance where merchantUserId="+userId+" ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!title.equals("")) {
            sqlStr.append(" and title LIKE '%"+title+"%' ");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and createTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and createTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        sqlStr.append(" limit ");
        sqlStr.append((page-1)*pageSize);
        sqlStr.append(",");
        sqlStr.append((pageSize));
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    public static String getBalanceList3Number(Map params){
        int userId = Integer.valueOf(String.valueOf(params.get("userId")));
        String balanceType = String.valueOf(params.get("balanceType"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        String title = String.valueOf(params.get("title"));
        String orderNo = String.valueOf(params.get("orderNo"));
        String serviceStaffName = String.valueOf(params.get("serviceStaffName"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_balance where merchantUserId="+userId+" ");
        if (!serviceStaffName.equals("")) {
            sqlStr.append(" and serviceStaffName LIKE '%"+serviceStaffName+"%' ");
        }
        if (!title.equals("")) {
            sqlStr.append(" and title LIKE '%"+title+"%' ");
        }
        if (!balanceType.equals("")) {
            sqlStr.append(" and balanceType = '");
            sqlStr.append(balanceType);
            sqlStr.append("'");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and createTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and createTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }


    public static String getActivityOrderList(Map params){
        int page = Integer.valueOf(String.valueOf(params.get("page")));
        int pageSize = Integer.valueOf(String.valueOf(params.get("pageSize")));
        String orderNo = String.valueOf(params.get("orderNo"));
        String activityName = String.valueOf(params.get("activityName"));
        String userName = String.valueOf(params.get("userName"));
        String userPhone = String.valueOf(params.get("userPhone"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_balance where 1=1 ");
        if (!activityName.equals("")) {
            sqlStr.append(" and activityName LIKE '%"+activityName+"%' ");
        }
        if (!userName.equals("")) {
            sqlStr.append(" and title LIKE '%"+userName+"%' ");
        }
        if (!userPhone.equals("")) {
            sqlStr.append(" and userPhone LIKE '%"+userPhone+"%' ");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and registrationTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and registrationTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        sqlStr.append(" limit ");
        sqlStr.append((page-1)*pageSize);
        sqlStr.append(",");
        sqlStr.append((pageSize));
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }

    public static String getActivityOrderListNumber(Map params){
        String orderNo = String.valueOf(params.get("orderNo"));
        String activityName = String.valueOf(params.get("activityName"));
        String userName = String.valueOf(params.get("userName"));
        String userPhone = String.valueOf(params.get("userPhone"));
        String startTime = String.valueOf(params.get("startTime"));
        String endTime = String.valueOf(params.get("endTime"));
        //拼装sql
        StringBuffer sqlStr = new StringBuffer();
        sqlStr.append("select count(*) from fks_balance where 1=1 ");
        if (!activityName.equals("")) {
            sqlStr.append(" and activityName LIKE '%"+activityName+"%' ");
        }
        if (!userName.equals("")) {
            sqlStr.append(" and title LIKE '%"+userName+"%' ");
        }
        if (!userPhone.equals("")) {
            sqlStr.append(" and userPhone LIKE '%"+userPhone+"%' ");
        }
        if (!startTime.equals("")) {
            sqlStr.append(" and registrationTime > '");
            sqlStr.append(startTime);
            sqlStr.append("'");
        }
        if (!endTime.equals("")) {
            sqlStr.append(" and registrationTime < '");
            sqlStr.append(endTime);
            sqlStr.append("'");
        }
        if (!orderNo.equals("")) {
            sqlStr.append(" and orderNo LIKE '%"+orderNo+"%' ");
        }
        System.out.println("灵灵享租采购列表数量--"+sqlStr.toString());
        return sqlStr.toString();
    }



}
